package com.itheima.health.common;

import com.itheima.health.common.pojo.UserInfo;

/**
 * @author 施子安
 * @version 1.0
 * @date 2023/4/29 10:44
 * @Description 用户ID工具类
 */
public class BaseContext {
    /**
     * 用户ID
     */
    public static final ThreadLocal<UserInfo> THREAD_LOCAL_USER = new ThreadLocal<>();

    /**
     * 设置当前线程的用户信息
     */
    public static void setCurrentUser(UserInfo currentUser) {
        THREAD_LOCAL_USER.set(currentUser);
    }

    /**
     * 获取当前线程的用户信息
     */
    public static UserInfo getCurrentUser() {
        return THREAD_LOCAL_USER.get();
    }
}
